$(document).ready(function () {

    // 保存到某路径下
    $('#download_to_path').click(function () {
        downloadToPath();
    });

    // 通过浏览器下载
    $('#download_by_browser').click(function () {
        downloadWordByBrowser();
    });
});

function downloadToPath() {
    // 请求数据
    var data = {
        name: 'user',
        age: 10,
        address: 'beijing'
    };
    // 开始请求
    $.ajax({
        type: "post",
        url: "/save/path",
        contentType: "application/json;charset=UTF-8",
        data: encodeURIComponent(JSON.stringify(data)),
        complete: function () {
            console.log('complete')
        }
    });
}


function downloadWordByBrowser() {
    window.location.href = "/browser";
}